﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CsvLib;
using System.Data.SqlServerCe;

namespace shopassient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //CsvStreamReader csr = new CsvStreamReader(@"C:\Documents and Settings\Administrator\桌面\8.20号秋装数据包\11.csv");
            //DataTable dt = csr[1, -1, 1, -1];
            //foreach (DataRow row in dt.Rows)
            //{
            //    for (int i = 0; i < row.Table.Columns.Count; i++)
            //    {
            //        string s = row[i].ToString();
            //    }
            //}
            //CSV csv = new CSV(@"C:\Documents and Settings\Administrator\桌面\8.20号秋装数据包\goods.csv");
            //dataGridView1.DataSource = csv.readTable();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
        }

        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show(e.X.ToString());
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            MessageBox.Show(e.RowIndex.ToString());
        }

        private void 转换ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string shopexTitleMode = "\"*:本地商品类型\",\"bn:商品货号\",\"ibn:规格货号\",\"col:品牌\","+
                "\"col:规格\",\"col:市场价\",\"col:销售价\",\"col:成本价\",\"col:商品名称\",\"col:默认图片\","+
                "\"col:缩略图\",\"col:图片文件\",\"col:详细介绍\",\"col:商品简介\",\"col:重量\",\"col:单位\","+
                "\"col:库存\",\"col:上架\"\r\n";
            string shopexContentMode = "\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\",\"{15}\",\"{16}\",\"{17}\"\r\n";
            string code = dataGridView1.Rows[0].Cells["销售属性别名"].Value.ToString();
            string.Format(shopexContentMode, ""//0
                , dataGridView1.Rows[0].Cells["商家编码"].Value.ToString(),//1
                "",//2
               "",//3
                "尺码|颜色",//4
                dataGridView1.Rows[0].Cells["宝贝价格"].Value.ToString(),//5
                dataGridView1.Rows[0].Cells["宝贝价格"].Value.ToString(),//6
                "",//7
                dataGridView1.Rows[0].Cells["宝贝名称"].Value.ToString(),//8
                "",//9默认图片
                "",//缩略图
                "",//图片文件
                dataGridView1.Rows[0].Cells["宝贝描述"].Value.ToString(),//详细介绍
                "",//商品简介
                "",//重量
                "",//单位
                dataGridView1.Rows[0].Cells["宝贝数量"].Value.ToString(),//库存
                dataGridView1.Rows[0].Cells["销售属性别名"].Value.ToString());//上架
            string newstr = convert(
                "108.000000:200:QC035:1627207:28320;1627778:28315;"+
            "108.000000:200:QC035:1627207:28320;1627778:28317;"+
            "108.000000:200:QC035:1627207:28320;1627778:28316;"+
            "108.000000:200:QC035:1627207:3232484;1627778:28315;"+
            "108.000000:200:QC035:1627207:3232484;1627778:28317;"+
            "108.000000:200:QC035:1627207:3232484;1627778:28316;"+
            "108.000000:200:QC035:1627207:28341;1627778:28315;"+
            "108.000000:200:QC035:1627207:28341;1627778:28317;"+
            "108.000000:200:QC035:1627207:28341;1627778:28316;"+
            "108.000000:200:QC035:1627207:3232480;1627778:28315;"+
            "108.000000:200:QC035:1627207:3232480;1627778:28317;"+
            "108.000000:200:QC035:1627207:3232480;1627778:28316;");
           // MessageBox.Show(code);
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
        private string convert(string taobaoString)
        {
            string[] taobaoStrarr = taobaoString.Split(new char[] { ';' });
            if (taobaoStrarr.Length % 2 != 0)
                return null;
            for (int i = 0; i < taobaoStrarr.Length; i++)
            {
                if (i % 2 == 0)
                {
                    string[] taobaoInfo = taobaoStrarr[i].Split(new char[] { ':' });
                   
                }
                if (i % 2 == 1)
                {
                    
                }
                
                    
            }return null;
        }
        public string test()
        {
            string Data_Source = @"Data Source=d:\My Documents\visual studio 2010\Projects\shopassient\shopassient\bin\Debug\DB\nsdata.sdf;Uid=netshop;Pwd=netshop";
            
            System.Data.SqlServerCe.SqlCeEngine se = new System.Data.SqlServerCe.SqlCeEngine(Data_Source);
            System.Data.SqlServerCe.SqlCeConnection scon = new System.Data.SqlServerCe.SqlCeConnection(Data_Source);

            scon.Open();
            System.Data.SqlServerCe.SqlCeCommand cmd = scon.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from mima";
            System.Data.SqlServerCe.SqlCeDataReader reader = cmd.ExecuteReader();
            string str = "";
            while (reader.Read())
            {
                str = reader.GetString(reader.GetOrdinal("uid"));
                str = reader.GetString(reader.GetOrdinal("pwd"));
            }
            scon.Close();
            return null;
        }

        private void 测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            test();
        }
    }
}
